package com.baidu.mapapi;

import android.content.Context;
import android.location.GpsSatellite;
import android.location.GpsStatus;
import android.location.GpsStatus.Listener;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.wifi.ScanResult;
import android.os.Bundle;
import android.telephony.NeighboringCellInfo;
import android.util.Log;
import java.util.Iterator;
import java.util.List;

class e
{
  Location a = null;
  private LocationManager b = null;
  private LocationListener c = null;
  private Context d;
  private a e = null;
  private int f = 0;
  private GpsStatus g;

  public e(Context paramContext)
  {
    this.d = paramContext;
  }

  String a(int paramInt1, int paramInt2, int paramInt3, int paramInt4, List<NeighboringCellInfo> paramList, String paramString)
  {
    if ((paramInt3 == 0) || (paramInt4 == 0))
      return "";
    Object[] arrayOfObject = new Object[4];
    arrayOfObject[0] = Integer.valueOf(paramInt1);
    arrayOfObject[1] = Integer.valueOf(paramInt2);
    arrayOfObject[2] = Integer.valueOf(paramInt3);
    arrayOfObject[3] = Integer.valueOf(paramInt4);
    return paramString.concat(String.format("%d|%d|%d|%d", arrayOfObject));
  }

  public String a(List<ScanResult> paramList, String paramString)
  {
    Object localObject1 = "";
    int i = paramList.size();
    if (paramList.size() > 10)
      i = 10;
    int j = 0;
    Object localObject2;
    if (j < i)
      if (j == 0)
        if (((ScanResult)paramList.get(j)).level == 0)
          localObject2 = localObject1;
    while (true)
    {
      j++;
      localObject1 = localObject2;
      break;
      String str2 = ((String)localObject1).concat(((ScanResult)paramList.get(j)).BSSID.replace(":", ""));
      int m = ((ScanResult)paramList.get(j)).level;
      Object[] arrayOfObject2 = new Object[1];
      arrayOfObject2[0] = Integer.valueOf(m);
      localObject2 = str2.concat(String.format(";%d;", arrayOfObject2)).concat(((ScanResult)paramList.get(j)).SSID);
      continue;
      if (((ScanResult)paramList.get(j)).level == 0)
        return localObject1;
      String str1 = ((String)localObject1).concat("|").concat(((ScanResult)paramList.get(j)).BSSID.replace(":", ""));
      int k = ((ScanResult)paramList.get(j)).level;
      Object[] arrayOfObject1 = new Object[1];
      arrayOfObject1[0] = Integer.valueOf(k);
      localObject2 = str1.concat(String.format(";%d;", arrayOfObject1)).concat(((ScanResult)paramList.get(j)).SSID);
    }
  }

  void a()
  {
    if (this.d == null);
    do
    {
      return;
      Mj.UpdataGPS(0.0D, 0.0D, 0.0F, 0.0F, 0.0F, 0);
      if (this.c == null)
        this.c = new LocationListener()
        {
          public void onLocationChanged(Location paramAnonymousLocation)
          {
            if (paramAnonymousLocation != null)
            {
              Bundle localBundle = paramAnonymousLocation.getExtras();
              int i = 0;
              if (localBundle != null)
                i = localBundle.getInt("NumSatellite", 0);
              boolean bool = paramAnonymousLocation.hasAccuracy();
              float f = 0.0F;
              if (bool)
                f = paramAnonymousLocation.getAccuracy();
              Mj.UpdataGPS(paramAnonymousLocation.getLongitude(), paramAnonymousLocation.getLatitude(), (float)(3.6D * paramAnonymousLocation.getSpeed()), paramAnonymousLocation.getBearing(), f, i);
              e.this.a = paramAnonymousLocation;
            }
          }

          public void onProviderDisabled(String paramAnonymousString)
          {
            Mj.UpdataGPS(0.0D, 0.0D, 0.0F, 0.0F, 0.0F, 0);
            e.this.a = null;
          }

          public void onProviderEnabled(String paramAnonymousString)
          {
          }

          public void onStatusChanged(String paramAnonymousString, int paramAnonymousInt, Bundle paramAnonymousBundle)
          {
            switch (paramAnonymousInt)
            {
            default:
              return;
            case 0:
            case 1:
            }
            Mj.UpdataGPS(0.0D, 0.0D, 0.0F, 0.0F, 0.0F, 0);
            e.this.a = null;
          }
        };
      if (this.b == null)
        this.b = ((LocationManager)this.d.getSystemService("location"));
    }
    while (this.b == null);
    try
    {
      this.b.requestLocationUpdates("gps", 1000L, 0.0F, this.c);
      this.e = new a(null);
      this.b.addGpsStatusListener(this.e);
      return;
    }
    catch (Exception localException)
    {
      Log.d("InitGPS", localException.getMessage());
    }
  }

  public void a(int paramInt1, int paramInt2, long paramLong)
  {
    switch (paramInt1)
    {
    default:
      return;
    case 5000:
    }
    if (paramInt2 == 1)
    {
      a();
      return;
    }
    b();
  }

  public void a(List<ScanResult> paramList)
  {
    int i = -1 + paramList.size();
    int j = 1;
    int k;
    if ((i >= 1) && (j != 0))
    {
      k = 0;
      j = 0;
      label25: if (k < i)
      {
        if (((ScanResult)paramList.get(k)).level >= ((ScanResult)paramList.get(k + 1)).level)
          break label128;
        ScanResult localScanResult = (ScanResult)paramList.get(k + 1);
        paramList.set(k + 1, paramList.get(k));
        paramList.set(k, localScanResult);
      }
    }
    label128: for (int m = 1; ; m = j)
    {
      k++;
      j = m;
      break label25;
      i--;
      break;
      return;
    }
  }

  public boolean a(List<ScanResult> paramList1, List<ScanResult> paramList2)
  {
    if (paramList1 == paramList2)
      return true;
    if ((paramList1 == null) || (paramList2 == null))
      return false;
    int i = paramList1.size();
    int j = paramList2.size();
    if ((i == 0) || (j == 0))
      return false;
    int k = 0;
    int m = 0;
    String str;
    int i1;
    if (k < i)
    {
      str = ((ScanResult)paramList1.get(k)).BSSID;
      if (str == null)
        i1 = m;
    }
    while (true)
    {
      k++;
      m = i1;
      break;
      int n = 0;
      while (true)
        if (n < j)
        {
          if (str.equals(((ScanResult)paramList2.get(n)).BSSID))
          {
            i1 = m + 1;
            break;
          }
          n++;
          continue;
          return m >= i / 2;
        }
      i1 = m;
    }
  }

  public String b(List<ScanResult> paramList, String paramString)
  {
    Object localObject1 = "";
    int i = paramList.size();
    if (paramList.size() > 10)
      i = 10;
    int j = 0;
    Object localObject2;
    if (j < i)
      if (j == 0)
        if (((ScanResult)paramList.get(j)).level == 0)
          localObject2 = localObject1;
    while (true)
    {
      j++;
      localObject1 = localObject2;
      break;
      localObject2 = ((String)localObject1).concat(((ScanResult)paramList.get(j)).BSSID.replace(":", ""));
      continue;
      if (((ScanResult)paramList.get(j)).level == 0)
        return localObject1;
      localObject2 = ((String)localObject1).concat("|").concat(((ScanResult)paramList.get(j)).BSSID.replace(":", ""));
    }
  }

  void b()
  {
    try
    {
      if (this.b != null)
        this.b.removeUpdates(this.c);
      Mj.UpdataGPS(0.0D, 0.0D, 0.0F, 0.0F, 0.0F, 0);
      return;
    }
    catch (Exception localException)
    {
      while (true)
        Log.d("UnInitGPS", localException.getMessage());
    }
  }

  private class a
    implements GpsStatus.Listener
  {
    private a()
    {
    }

    public void onGpsStatusChanged(int paramInt)
    {
      int i;
      switch (paramInt)
      {
      case 3:
      default:
        return;
      case 4:
        if (e.a(e.this) == null)
          e.a(e.this, (LocationManager)e.b(e.this).getSystemService("location"));
        if (e.a(e.this) != null)
        {
          if (e.c(e.this) == null)
            e.a(e.this, e.a(e.this).getGpsStatus(null));
        }
        else
        {
          Iterator localIterator = e.c(e.this).getSatellites().iterator();
          i = 0;
          label119: if (!localIterator.hasNext())
            break label175;
          if (!((GpsSatellite)localIterator.next()).usedInFix())
            break label220;
        }
        break;
      case 2:
      }
      label175: label220: for (int j = i + 1; ; j = i)
      {
        i = j;
        break label119;
        e.a(e.this).getGpsStatus(e.c(e.this));
        break;
        if ((i < 3) && (e.d(e.this) >= 3))
          Mj.UpdataGPS(0.0D, 0.0D, 0.0F, 0.0F, 0.0F, 0);
        e.a(e.this, i);
        return;
        Mj.UpdataGPS(0.0D, 0.0D, 0.0F, 0.0F, 0.0F, 0);
        return;
      }
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.baidu.mapapi.e
 * JD-Core Version:    0.6.2
 */